package com.guigu.buy.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.buy.dto.Pur_Detal;
import com.guigu.buy.mapper.PurchaseOrderDetailsMapper;
import com.guigu.buy.pojo.PurchaseOrderDetails;
import com.guigu.buy.service.IPurchaseOrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author com.guigu
 * @since 2024-05-15
 */
@CrossOrigin
@Controller
@RequestMapping("/buy/purchaseOrderDetails")
public class PurchaseOrderDetailsController {
    @Autowired
    private IPurchaseOrderDetailsService purchaseOrderDetailsService;
    @Autowired
    private PurchaseOrderDetailsMapper purchaseOrderDetailsMapper;



    //根据订单编号查询详情采购单


    @RequestMapping("/Purchaseid/{parentId}")
    @ResponseBody
    public List<Pur_Detal> PurchaseId(@PathVariable int parentId) {
        return purchaseOrderDetailsMapper.queryAll(parentId);
    }


    //采购单明细回显
    @RequestMapping("/getByParentId/{id}")
    @ResponseBody
    public List<PurchaseOrderDetails> getByParentId(@PathVariable int id){
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("parent_id",id);
        return purchaseOrderDetailsService.list(wrapper);
    }
}
